package AOP;

import Messages.AMessage;

import jade.core.Profile;
import jade.core.ProfileException;
import jade.core.ProfileImpl;
import jade.core.Runtime;

import jade.tools.rma.rma;
import jade.wrapper.AgentController;
import jade.wrapper.ContainerController;
import jade.wrapper.StaleProxyException;

public class StartAgentPlatformOne 
{

	/**
	 * @param args
	 * @throws ProfileException 
	 */
	
	@SuppressWarnings("unused")
	public static void main(String[] args) throws ProfileException 
	{
		String host = "localhost";
		String port = "";
		String name = "AOP";
		
		ContainerController cController;
		Runtime rt = Runtime.instance();//retrieve the singleton instance of the JADE Runtime
		Profile p;
		//Create a container
		p = new ProfileImpl();
		cController = rt.createMainContainer(p);			
		rt.setCloseVM(true);
		
		
		
		if(cController != null)
		{
			try
			{
				//start GUI interface Agent
				AgentController ac = cController.createNewAgent("gui", rma.class.getName(), null);
				ac.start();
				
				//---add Agents in this zone---
				
				//add Agent - register agent into DF, receive acl msg, printout and reply
				CreateAgent(cController,"11"+AMessage.GlobalNames.OFFICE_REGION_AGENT.get(),"Agents.OfficeRegion");
				CreateAgent(cController,"01"+AMessage.GlobalNames.VACUUM_CLEANER_AGENT.get(),"Agents.VacuumCleaner");
				CreateAgent(cController,"02"+AMessage.GlobalNames.VACUUM_CLEANER_AGENT.get(),"Agents.VacuumCleaner");
				CreateAgent(cController,"03"+AMessage.GlobalNames.VACUUM_CLEANER_AGENT.get(),"Agents.VacuumCleaner");
				
				
			}
			catch (Exception e)
			{
				e.printStackTrace();
			}
		}	
	}
	
	private static void CreateAgent(ContainerController cController, String agent_name, String agent_class) throws StaleProxyException
	{
		//add Agent AgentSender
		AgentController ac = cController.createNewAgent(agent_name, agent_class, null);
		ac.start();
	}
}
